package cn.edu.scau.cmi.wujiaxian.exercise11;

import java.awt.event.InputEvent;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

import com.sun.glass.events.KeyEvent;

public class WindowMenu extends JFrame{

	private static final long serialVersionUID = -864985319409262442L;
	JMenuBar menuBar;
	JMenu menu;
	JMenu subMenu;
	JMenuItem item1;
	JMenuItem item2;
	
	public WindowMenu() {
	}
	
	public WindowMenu(String title, int x, int y, int w, int h) {
		init(title);
		setLocation(x, y);
		setSize(w, h);
		setVisible(true);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	}
	
	@SuppressWarnings("deprecation")
	void init(String title) {
		setTitle(title);
		menuBar = new JMenuBar();
		menu = new JMenu("菜单");
		subMenu = new JMenu("软件项目");
		item1 = new JMenuItem("Java话题");
		item2 = new JMenuItem("动画话题");
		item1.setAccelerator(KeyStroke.getKeyStroke('A'));
		item2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
		menu.add(item1);
		menu.addSeparator();
		menu.add(item2);
		menu.add(subMenu);
		subMenu.add(new JMenuItem("汽车销售系统"));
		subMenu.add(new JMenuItem("农村信息系统"));
		menuBar.add(menu);
		setJMenuBar(menuBar);
	}
	
}
